package com.zmc.coupon.config.mq;


import com.zmc.common.constant.QueueConstant;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @author zmc
 * 延时关单
 */
@Configuration
public class CouponReturnQueueConfig {


    @Bean("couponReturnExchange")
    public Exchange orderExchange() {
        return new TopicExchange(QueueConstant.COUPON_RETURN_EXCHANGE, true, false);
    }

    @Bean("couponReturnQueue")
    public Queue orderQueue() {
        return QueueBuilder.durable(QueueConstant.COUPON_RETURN_QUEUE).build();
    }

    @Bean("couponReturnBinding")
    public Binding orderBinding(@Qualifier("couponReturnQueue") Queue queue, @Qualifier("couponReturnExchange")Exchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with(QueueConstant.COUPON_RETURN_ROUTING_KEY).noargs();
    }


}
